<?php
include_once('common.inc.php');
include_once(__ROOT__.'model/task.class.php');

$act = get_param('action');
$taskModel = new TaskModel;

switch( $act ):

case 'add':
	if( get_param('name') ){
		$data = get_data('task');
		$rs = $taskModel->add_task($data);	
		if( $rs ){
			echo '<p>Success!</p>';
		}else{
			echo '<p>'.$taskModel->get_error().'</p>';
		}
	}
	echo '
		<fieldset>
			<legend>添加功能</legend>
			<form action="task.php?action=add" method="post">
				<p>
					<label for="name">功能名称:</label>
					<input type="text" name="name" />
				</p>
				<p>
					<label for="url">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;URL:</label>
					<input type="text" name="url" />
				</p>
				<p>
					<input type="submit" value="Submit" name="submit"  />
				</p>
			</form>
		</fieldset>
	';
break;

endswitch;
